<template>
  <!--评分 标段节点下 所有投标人 打分 明细 -->
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :expandedRowKeys="expandedRowKeys"
        :defaultExpandAllRows="true"
      >
      </a-table>
    </div>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction, postAction } from '@api/manage'

export default {
  name: 'PfExpertDetail',
  components: {},
  props: {},
  data () {
    return {
      description: '评分明细',
      // 表头
      columns: [
        {
          title: ' ',
          align: 'left',
          dataIndex: 'name'
        },
        {
          title: '指标名称',
          align: 'left',
          dataIndex: 'indicatorName'
        },
        {
          title: '指标类型',
          align: 'left',
          dataIndex: 'indicatorType'
        },
        {
          title: '分值',
          align: 'left',
          dataIndex: 'score'
        },
        {
          title: '最小分值',
          align: 'left',
          dataIndex: 'scoreMin'
        },
        {
          title: '最大分值',
          align: 'left',
          dataIndex: 'scoreMax'
        },

        {
          title: '权重',
          align: 'left',
          dataIndex: 'weight'
        },

        {
          title: '评审说明',
          align: 'left',
          dataIndex: 'description'
        },
        {
          title: ' ',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        // 根据投标人查询
        queryExpertPfRecordByTender: '/exPingbiao/exPingbiaoExpertRecord/queryExpertPfRecordByTender',
        // 根据专家查询
        queryTenderPfRecordByExpert: '/exPingbiao/exPingbiaoExpertRecord/queryTenderPfRecordByExpert'
      },
      dataSource: [],
      expandedRowKeys: []
    }
  },
  watch: {},
  created () {

  },
  mounted(){
    this.loadData()
  },
  computed: {},
  methods: {
    /**
     * @param realBusinessId
     * @param businessType 综合、技术
     */
    loadData (tenderId, realBusinessId, businessType) {
      var that = this
      // let params = {
      //   expertId: '1860122830859960321',
      //   businessId: '1861781871480549378',
      //   businessType: '技术指标'
      // }
      let params = {
        expertId: tenderId,
        businessId: realBusinessId,
        businessType: businessType
      }
      getAction(this.url.queryTenderPfRecordByExpert, params)
        .then((res) => {
          if (res.success) {
            let result = res.result
            this.initExpandedRowKey(result)
            this.dataSource = result
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {})
    },
    initExpandedRowKey (list) {
      list.forEach(item => {
        (item.scoreList || []).forEach(scoreItem => {
          let find = this.columns.find(e => e.dataIndex == scoreItem.id)
          if (!find) {
            this.columns.push({
              title: scoreItem.name,
              dataIndex: scoreItem.id
            })
          }
          item[scoreItem.id] = scoreItem.score
        })
        this.expandedRowKeys.push(item.id)
        if (item.children && item.children.length > 0) {
          this.initExpandedRowKey(item.children)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
